# coding=utf-8
"""
共通类库
"""
__author__ = 'liubin'

import json
from concurrent.futures import ThreadPoolExecutor

import jsonpickle

# 整个程序的线程池
# 设置线程池大小
EXECUTOR = ThreadPoolExecutor(16)


def to_json_str(obj):
    """
    python对象转化为json字符串
    :param obj:
    :return:
    """
    return jsonpickle.encode(obj, unpicklable=False)


def to_json(obj):
    """
    python对象转化为json对象
    handler返回时使用这个
    :param obj:
    :return:
    """
    return json.loads(to_json_str(obj))
